/**
 * Created by AllanXu on 7/25/2016.
 */
define(function (require) {
	var Vue = require('vue'),
        Config = require('config'),
		_ = require('ajax'),
		utilities = require('utilities');

	var app = new Vue({
		el: '#add_page',
		data: {
            renderObj: {
                listArr: []
            },
		},
		methods:{
			init: function () {
				_(Config.SERVICE.INDEX.ADD, 
                {}, 
                function(data) {
                    app.renderObj.listArr = data.obj.child;
                });
			},
            select: function(item,add){
                console.log(item,add)
                if(item===''&&add===''){
                    sessionStorage.removeItem('addName');
                    sessionStorage.setItem('addName', "江西省");

                    sessionStorage.removeItem('addCode');
                    sessionStorage.setItem('addCode', 36);
                }else{

                    if(add.code){
                        var addCode = add.code;
                        var addName = item.name+add.name;
                        console.log(JSON.parse(JSON.stringify(add.code)),222);
                    }else {
                        var addCode = item.code;
                        var addName = item.name;
                        console.log(JSON.parse(JSON.stringify(item.code)));
                    }

                    sessionStorage.removeItem('addName');
                    sessionStorage.setItem('addName', addName);

                    sessionStorage.removeItem('addCode');
                    sessionStorage.setItem('addCode', addCode);
                }

            }
		}
	});
	app.init();
});